<template>
	<view class="add_comm">
		<view class="add_comm_title">小区信息</view>
		<view class="ele_title_left bg-white padding-left-sm padding-bottom-xs">
			<view class="ele_title_inner padding-xs">{{obj.residential_quarters_name}}</view>
			<view class="ele_address">
				<image class="ele_address_img" src="../../../common/img/dizhi_hui.png" mode=""></image>
				<text>{{obj.residential_quarters_address}}</text>
			</view>   
		</view>
		<view class="add_comm_title">支出信息</view>
		<view class="add_box">
			<view class="add_inner">
				<view class="add_inner_text">支出名称</view>
				<input class="add_inner_input" type="text" @input="zname" value="" placeholder="请输入支出名称" />
			</view>
			<view class="add_inner">
				<view class="add_inner_text">支出时间</view>
				<picker mode="date" :value="date" start="2015-09-01" end="2099-09-01" @change="DateChange">
					<view class="picker">
						{{date}}
					</view>
				</picker>
			</view>
			<view class="add_inner">
				<view class="add_inner_text">支出金额</view>
				<input class="add_inner_input" type="text" value="" @input="zmoney" placeholder="请输入支出金额" />
			</view>
			<view class="add_inner">
				<view class="add_inner_text">支出备注</view>
				<input class="add_inner_input" type="text" value="" @input="zremark" placeholder="请输入支出备注" />
			</view>
		</view>
		<view class="add_text_btn" @tap="saveInfo" >保存</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				obj:[],
				residential_quarters_guid:'',//	字符串	小区标识	是
				name_of_expenditure:'',//	字符串	支出名称	是
				date: '2021-01-01',//	字符串	支出时间	是
				expenditure_amount:0.00,//	浮点型	支出金额	是
				remark:'',//	字符串	备注	否
                
			}
		},
		onLoad(options) {
		   this.obj=JSON.parse(options.item);
		},
		methods: {
			zname(e){
				this.name_of_expenditure = e.detail.value;
			},
			ztime(e){
				this.spending_time = e.detail.value;
			},
			zmoney(e){
				this.expenditure_amount = e.detail.value;
			},
			zremark(e){
				this.remark = e.detail.value;
			},
			DateChange(e) {
				this.date = e.detail.value
			},
			saveInfo(){
				let that=this;
				if(this.name_of_expenditure.trim()=='' || this.name_of_expenditure.trim()==null){
					uni.showToast({
						icon: 'none',
					    title: '支出名称不能为空'
					});
					return;
				}
				if(this.expenditure_amount.trim()=='' || this.expenditure_amount.trim()==null){
					uni.showToast({
						icon: 'none',
					    title: '支出金额不能为空'
					});
					return;
				}
				that.http.tokenreq({
					url: 'costcontrol/v1/add',
					data: {
				    "residential_quarters_guid":this.obj.residential_quarters_guid,
					"name_of_expenditure":this.name_of_expenditure,
					"spending_time":this.date,
					"expenditure_amount":this.expenditure_amount,
					"remark":this.remark
					}
				}).then((res) => {
					let e=res.data;
					if(e.code==0 && e.success){
						uni.showModal({
							content: e.message,
							showCancel:false,
							success: function (res) {
								if (res.confirm) {
									uni.redirectTo({
										url: '/pages/costing/plotCost/plotCost?item='+JSON.stringify(that.obj)
									})
								}
							}
						});
					}else{
						uni.showToast({
							icon: 'none',
						    title: e.message
						});
					}
				})
			}
		}
	}
</script>

<style>

</style>
